package fourEightDays;

import java.util.Scanner;

public class Day21 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int[] target = new int[n];
            for (int i = 0; i < n; i ++) {
                target[i] = i + 1;
            }
            in.nextLine(); // 吃空格
            char[] cmd = in.nextLine().toCharArray();
            // 一般情况：窗口为 4，数据大于等于 4
            int start = 0;
            int end = 3;
            int pos = 0;
            // 特殊情况歌曲数量小于 4 时
            if (n < 4) {
                start = 0;
                end = n - 1;
            }
            for (int i = 0; i < cmd.length; i ++) {
                if (cmd[i] == 'U') {
                    if (pos == 0) {
                        if (n >= 4) {
                            end = n - 1;
                            start = end - 3;
                            pos = end;
                        } else {
                            end = n - 1;
                            start = 0;
                            pos = end;
                        }
                    } else {
                        pos --;
                        if (pos < start && pos != 0) {
                            start --;
                            end --;
                        }
                    }
                } else if (cmd[i] == 'D') {
                    if (pos == n - 1) {
                        if (n >= 4) {
                            start = 0;
                            end = 3;
                            pos = start;
                        } else {
                            start = 0;
                            end = n - 1;
                            pos = start;
                        }
                    } else {
                        pos ++;
                        if (pos > end && pos != n - 1) {
                            start ++;
                            end ++;
                        }
                    }
                }
            }
            for (int i = start; i <= end; i++) {
                System.out.print(target[i] + " ");
            }
            System.out.println();
            System.out.println(target[pos]);
        }
    }
}
